package com.retailers.generator.service.Impl.mybatisv2;

import com.retailers.generator.bean.ColumnBean;
import com.retailers.generator.bean.TableBean;
import com.retailers.generator.service.Impl.AbsMybatisGen;
import com.retailers.generator.service.Impl.mybatisv2.mapper.GeneratorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


//@Service
public class GeneratorServiceImpl  extends AbsMybatisGen {
	@Autowired
	GeneratorMapper generatorMapper;




	@Override
	public List<TableBean> tablesList() {
		List<TableBean> list = generatorMapper.list();
		for (TableBean tableBean : list) {
			tableBean.setClassName(tableToJava(tableBean.getTableName(),""));
		}
		return list;
	}

	@Override
	public List<ColumnBean> getColumns(String table) throws Exception {
		List<ColumnBean> list = generatorMapper.listColumns(table);
		for (ColumnBean columnBean : list) {
			String str=replaceUnderLine2UpperCase(columnBean.getColumnName());
			columnBean.setAttrname(str);
		}
		return list;
	}

}
